package jmine.tec.datadigester.positional.writer;

import jmine.tec.datadigester.positional.meta.PositionalLongFieldMetadata;

/**
 * {@link PositionalFieldWriter} para campos do tipo Long
 * 
 * @author israel.crisanto
 */
public class LongPositionalFieldWriter extends AbstractPositionalFieldWriter<PositionalLongFieldMetadata> {

    /**
     * Construtor
     * 
     * @param fieldMetadata fieldMetadata
     */
    public LongPositionalFieldWriter(PositionalLongFieldMetadata fieldMetadata) {
        super(fieldMetadata);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Object read(String line) {
        PositionalLongFieldMetadata meta = this.getFieldMetadata();
        String data = line.substring(meta.start(), meta.start() + meta.size());
        return Long.parseLong(data);
    }

}
